package com.stu.design_patterns.proxy._01_static_proxy;
// 婚礼新人要亲自参加，婚庆公司忙前忙后
// 业务接口——婚礼
public interface Marry {
  // 真实业务——结婚
  void happyMarry();
}

// 代理角色——婚庆公司
class MarryProxy implements Marry {
  private Marry marry;
  public MarryProxy(Marry newcomer) { marry = newcomer; }
  @Override
  public void happyMarry() {
    before();// 忙前
    marry.happyMarry();// 结婚
    after();// 忙后
  }
  private void before() {
    System.out.println("布置酒席");
  }
  private void after() {
    System.out.println("打扫卫生");
  }
}

// 真实角色——要结婚的人
class Newcomer implements Marry {
  @Override
  public void happyMarry() { System.out.println("一对新人结为夫妻"); }
}

class Main {
  public static void main(String[] args) {
    Marry marry = new MarryProxy(new Newcomer());
    marry.happyMarry();
  }
}
